#!/usr/bin/python3
import RPi.GPIO as RG
import time


class MultipleLED:

    def __init__(self, pins: list):
        self.pins = pins

    def init(self):
        RG.setmode(RG.BCM)
        RG.setup(self.pins, RG.OUT, initial=RG.LOW)
        RG.output(self.pins[0], RG.HIGH)

    def loop(self):
        now = 0
        while True:
            time.sleep(1)
            now = 0 if now > len(self.pins) - 2 else now + 1
            RG.output(self.pins, RG.LOW)
            RG.output(self.pins[now], RG.HIGH)

    def destroy(self):
        RG.output(self.pins, RG.LOW)
        RG.cleanup()


if __name__ == "__main__":
    rg_list = list(map(lambda x: int(x), input("输入GPIO接口值，每个GPIO英文逗号分开: ").split(",")))
    m_led = MultipleLED(rg_list)
    try:
        m_led.init()
        m_led.loop()
    except KeyboardInterrupt:
        m_led.destroy()
        print("中断完成")
